package People;

public class Student implements Comparable {
    private String name;
    private double score;
    public Student(String name,double score){
        this.name=name;
        this.score=score;
    }
    @Override
    public String toString(){
        return "["+this.name+":"+this.score+"]";
    }

    @Override
    public int compareTo(Object o) {
        Student student=(Student) o;
        if(this.score>student.score){
            return -1;
        } else if (this.score<student.score) {
            return 1;
        }else {
            return 0;
        }
    }

    //sort方法中会自动调用compareTo方法，  这个方法的参数是Object
    //其实也就是传入的是Student类型

}
